﻿using System;
using System.Windows;
using System.Windows.Data;

namespace MalRec.Base.Converter
{
    public class BooleanToInvertedVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is bool || value is Boolean))
            {
                throw new InvalidOperationException("Value must be of type Bool");
            }
            return ((bool)value) ? Visibility.Collapsed : Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is Visibility))
            {
                throw new InvalidOperationException("Value must be of type Visibility");
            }
            return ((Visibility)value) == Visibility.Visible ? false : true;
        }
    }
}